package com.ruoyi.airspaceFlight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.airspaceFlight.domain.TTaskNature;
import com.ruoyi.airspaceFlight.service.ITTaskNatureService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 任务性质Controller
 * 
 * @author zc
 * @date 2023-10-30
 */
@RestController
@RequestMapping("/task")
public class TTaskNatureController extends BaseController
{
    @Autowired
    private ITTaskNatureService tTaskNatureService;

    /**
     * 查询任务性质列表
     */
    @RequiresPermissions("lowair-airspace-flight:task:list")
    @GetMapping("/list")
    public TableDataInfo list(TTaskNature tTaskNature)
    {
        startPage();
        List<TTaskNature> list = tTaskNatureService.selectTTaskNatureList(tTaskNature);
        return getDataTable(list);
    }

    /**
     * 导出任务性质列表
     */
    @RequiresPermissions("lowair-airspace-flight:task:export")
    @Log(title = "任务性质", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TTaskNature tTaskNature)
    {
        List<TTaskNature> list = tTaskNatureService.selectTTaskNatureList(tTaskNature);
        ExcelUtil<TTaskNature> util = new ExcelUtil<TTaskNature>(TTaskNature.class);
        util.exportExcel(response, list, "任务性质数据");
    }

    /**
     * 获取任务性质详细信息
     */
    @RequiresPermissions("lowair-airspace-flight:task:query")
    @GetMapping(value = "/{taskNatureId}")
    public AjaxResult getInfo(@PathVariable("taskNatureId") String taskNatureId)
    {
        return AjaxResult.success(tTaskNatureService.selectTTaskNatureByTaskNatureId(taskNatureId));
    }

    /**
     * 新增任务性质
     */
    @RequiresPermissions("lowair-airspace-flight:task:add")
    @Log(title = "任务性质", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TTaskNature tTaskNature)
    {
        return toAjax(tTaskNatureService.insertTTaskNature(tTaskNature));
    }

    /**
     * 修改任务性质
     */
    @RequiresPermissions("lowair-airspace-flight:task:edit")
    @Log(title = "任务性质", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TTaskNature tTaskNature)
    {
        return toAjax(tTaskNatureService.updateTTaskNature(tTaskNature));
    }

    /**
     * 删除任务性质
     */
    @RequiresPermissions("lowair-airspace-flight:task:remove")
    @Log(title = "任务性质", businessType = BusinessType.DELETE)
	@DeleteMapping("/{taskNatureIds}")
    public AjaxResult remove(@PathVariable String[] taskNatureIds)
    {
        return toAjax(tTaskNatureService.deleteTTaskNatureByTaskNatureIds(taskNatureIds));
    }
}
